package com.taobao.machinesystem.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taobao.machinesystem.entity.SysEquipmenttype;
import com.taobao.machinesystem.entity.vo.SysEquipmentTypeQueryVo;
import com.taobao.machinesystem.mapper.SysEquipmenttypeMapper;
import com.taobao.machinesystem.service.SysEquipmenttypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
 * <p>
 * 设备类型 服务实现类
 * </p>
 *
 * @author LiuJunCheng
 * @since 2022-04-22
 */
@Service
public class SysEquipmenttypeServiceImpl extends ServiceImpl<SysEquipmenttypeMapper, SysEquipmenttype> implements SysEquipmenttypeService {

    @Override
    public Page<SysEquipmenttype> listSysEquipmenttype(Integer currentPage, Integer size, SysEquipmentTypeQueryVo sysEquipmentTypeQueryVo) {
        Page<SysEquipmenttype> sysCompanPage = new Page<>(currentPage, size);

        QueryWrapper<SysEquipmenttype> queryWrapper = new QueryWrapper<>();

        if (!StringUtils.isEmpty(sysEquipmentTypeQueryVo.getCode())) {
            queryWrapper.eq("CODE", sysEquipmentTypeQueryVo.getCode());
        }
        if (!StringUtils.isEmpty(sysEquipmentTypeQueryVo.getName())) {
            queryWrapper.likeLeft("NAME", sysEquipmentTypeQueryVo.getName());
        }
        
        return baseMapper.selectPage(sysCompanPage, queryWrapper);
    }
}
